package com.example.datapedestal.toolChain.entity;
import com.example.datapedestal.toolChain.service.ToolPlugin;

import java.time.Duration;
import java.time.Instant;

public class ToolA implements ToolPlugin {
    private int total_entries = 100;  // 需要根据业务进行查询
    private int completedEntries = 0;  
    private Instant startTime;  
  
    @Override  
    public void execute() {  
        startTime = Instant.now();  
        for (int i = 0; i < total_entries; i++) {  
            completedEntries++;  
            // ... 执行其他逻辑 ...  
        }  
    }  
  
    @Override  
    public String getName() {  
        return "PluginA";  
    }  
  
    @Override  
    public int getProgressPercentage() {  
        return (completedEntries * 100) / total_entries;  
    }  
  
    @Override  
    public long getElapsedTime() {  
        return Duration.between(startTime, Instant.now()).toMillis();  
    }  
  
    @Override  
    public long getEstimatedTimeLeft() {  
        // 假设剩余时间按已完成时间的比例计算  
        double progress = (double) completedEntries / total_entries;  
        return (long) (getElapsedTime() / progress - getElapsedTime());  
    }  
  
    @Override  
    public int getTotalEntries() {  
        return total_entries;
    }  
  
    @Override  
    public int getCompletedEntries() {  
        return completedEntries;  
    }  
}